"""
file_object = open('log.txt', mode='r', encoding='utf-8')  # 打开文件

content = file_object.read()  # 读文件
print(content)
file_object.close()  # 关闭文件
"""
"""
file_object = open('log.txt', mode='a', encoding='utf-8')  # 打开文件

file_object.write("你好")
file_object.close()
"""
# file_object = open('log.txt', mode='r+', encoding='utf-8')  # 打开文件
#
# content = file_object.read()
# print(content)
# file_object.seek(3)  # 移到第三个字节的意思，seek移动的是光标
# file_object.write('666')
# file_object.close()
"""可写可读
file_object = open('log.txt', mode='w+', encoding='utf-8')  # 打开文件
data = file_object.read()
print(data)
file_object.write('youdade')
file_object.seek(0)

data = file_object.read()
print(data)
file_object.close()
"""
""""
file_object = open('log.txt', mode='a+', encoding='utf-8')  # 打开文件
file_object.seek(0)
data=file_object.read()
print(data)#追加在后面，所以读不到 ,只要你一写永远在后面

file_object.close()
"""
"""
file_object = open('log.txt', mode='r', encoding='utf-8')  # 打开文件
data=file_object.readlines()
print(data)
file_object.close()
"""
# 当你要读取一个大文件时
# file_object = open('log.txt', mode='r', encoding='utf-8')  # 打开文件
# for line in file_object:
#     line  = line.strip()
#     print(line)
# file_object.close()
file_object = open('log.txt', mode='w', encoding='utf-8')  # 打开文件

file_object.write("你好\n")
file_object.write('sdqwfcds')

file_object.close()